<template>
<div class="side-bar">
  <div class="item ff-cn flex-center hand" @click="openCart" v-if="hasCart">
    <i class="iconfont icon-cart"></i>
    <div class="title fs-n">购物车</div>
    <p class="tac omit cart-num">{{cartList.length}}</p>
  </div>
  <!-- <div class="item ff-cn flex-center hand">
    <i class="iconfont icon-fuwu"></i>
    <div class="title fs-n">客服</div>
  </div> -->
  <div class="item ff-cn flex-center hand" v-if="siteConfig && siteConfig.contact_phone">
    <i class="el-icon-phone"></i>
    <div class="title fs-n">电话</div>
    <div class="content">
      <div class="wrap fs-b">
        <div class="pd1" style="width: 113px;">{{siteConfig.contact_phone}}</div>
      </div>
    </div>
  </div>
  <div class="item ff-cn flex-center hand" v-if="siteConfig && siteConfig.full_qrcodeurl">
    <i class="iconfont icon-weixin"></i>
    <div class="title fs-n">微信</div>
    <div class="content">
      <div class="wrap">
        <div class="tip tac mgb1 fs-n">微信扫一扫<br />关注公众号</div>
        <img style="width: 120px;" :src="siteConfig.full_qrcodeurl">
      </div>
    </div>
  </div>
  <div class="item ff-cn flex-center hand" v-back-top>
    <i class="el-icon-arrow-up"></i>
    <div class="title fs-n">回顶部</div>
  </div>

  <Cart ref="Cart" />
</div>
</template>

<script>
import { mapGetters } from 'vuex'

export default {
  components: {
    Cart: _ => import('@/components/common/Cart'),
  },
  data() {
    return {
      hasCart: false,
    }
  },
  computed: {
    ...mapGetters(['cartList', 'siteConfig']),
  },
  watch: {
    '$route.name': {
      handler(val) {
        console.log(val)
        if (val == 'panomarketDetail' || val == 'panomarket') {
          this.hasCart = true
        } else {
          this.hasCart = false
        }
      },
      immediate: true,
    }
  },
  methods: {
    openCart() {
      this.$store.dispatch('getCartList')
      this.$refs.Cart.openDialog()
    }
  }
}
</script>

<style lang="stylus" scoped>
.side-bar {
  position: fixed;
  right: 0;
  bottom: 100px;
  z-index: 9;
  border: 1px solid #eee;
}
.side-bar .item {
  padding: 5px;
  -webkit-box-shadow: 2px 2px 6px rgba(0,0,0,0.1);
  box-shadow: 2px 2px 6px rgba(0,0,0,0.1);
  background-color: #fff;
  color: #333333;
  -webkit-transition: all 0.3s;
  -o-transition: all 0.3s;
  transition: all 0.3s;
  position: relative;
  border-bottom: 1px solid #eee;
}
.side-bar .item:last-child {
  border-bottom: 0;
}
.side-bar .item:hover {
  background-color: var(--themeColor);
  color: #fff;
}
.side-bar .item .cart-num {
  width: 36px;
  color: var(--themeColor);
  font-size: 12px;
  padding: 2px 0;
}
.side-bar .item:hover {
  .cart-num {
    color: #fff;
  }
}
.side-bar .item:hover .content {
  width: auto;
  right: 48px;
}
.side-bar i {
  font-size: 26px;
}
.side-bar .content {
  width: 0;
  position: absolute;
  right: -100%;
  top: 0;
  -webkit-transition: right 0.5s;
  -o-transition: right 0.5s;
  transition: right 0.5s;
  overflow: hidden;
}
.side-bar .content:after {
  content: '';
  position: absolute;
  right: 3px;
  top: 16px;
  width: 0;
  height: 0;
  border-top: 10px solid transparent;
  border-left: 10px solid var(--themeColor);
  border-bottom: 10px solid transparent;
}
.side-bar .content .wrap {
  border-radius: 6px;
  background-color: var(--themeColor);
  margin-right: 13px;
  padding: 10px;
}
.side-bar .content .wrap textarea {
  border: none;
  padding: 3px;
  border-radius: 5px;
  width: 230px;
}
</style>